<?php if(!defined('ROOT_PATH')) exit('Access Denied');?><dl class="Tabs">
  <dt id="PostsTabs"><a href="#tabPostAdd" <?php if($pages == 0) { ?>class="select"<?php } ?> >添加</a> <a href="#tabPostList" <?php if($pages == 1) { ?>class="select"<?php } ?>>列表</a></dt>
  <dd id="tabPostAdd" style="display: <?php if($pages == 0) { ?>block<?php } else { ?>none<?php } ?>; ">
    <form action="/admin.php/Admin_Articles/add" method="post" name="add_post" id="add-post">
      <div id="add-post">
        <ul id="add-post-option">
          <li>
            <label for="add-post-title" class="add-post-label">标题：</label>
            <input type="text" id="add-post-title" name="title" value="" class="add-post-text" />
          </li>
          <li>
             <label  class="add-post-label">栏目分类：</label>
          <select name="categories" size="1" class="add-post-select">
            <option value="0" selected="selected">---顶级分类---</option>
            <?php if(is_array($catdata)) foreach($catdata AS $vlaue) { ?>
            <option value="<?php echo $vlaue["id"];?>"><?php echo $vlaue["name"];?></option>
            <?php } ?>

          </select>
          </li>
          <li>
            <label class="add-post-label">设置：</label>
            <input id="add-post-allowComment" name="iscomment" type="checkbox" value="1" checked="true">
            <label for="add-post-allowComment">允许评论</label>
            <input id="add-post-top" name="top" type="checkbox" value="1">
            <label for="add-post-top">置顶文章</label>
            <input id="add-post-top" name="hot" type="checkbox" value="50">
            <label for="add-post-top">热门文章</label>
          </li>
          <li>
           <label for="add-post-tags" class="add-post-label">内容：</label>
           <div id="contentcen-sapn">
           <textarea id="contentcen" name="contentcen" style="width:800px;height:400px;visibility:hidden;"></textarea></div>
            </li>
             <li>
            <label  class="add-post-label">关键字：</label>
            <textarea  class="add-post-textarea" name="keywords"  autocomplete="off"></textarea>
          </li>
           <li>
            <label  class="add-post-label">描述：</label>
            <textarea class="add-post-textarea" name="description"  autocomplete="off"></textarea>
          </li>
          <li>
            <label for="add-post-tags" class="add-post-label">标签：</label>
            <input id="add-post-tags" name="tags" type="text" value="" class="add-post-text" autocomplete="off">
         
           </li>
          <label for="add-post-tags" class="add-post-label"></label>
          <input type="submit" id="add-post-submit" name="add-post-submit" value="添加文章" />
          </li>
        </ul>
      </div>
    </form>
  </dd>
  <dd id="tabPostList" style="display: <?php if($pages == 0) { ?>none<?php } else { ?>block<?php } ?>; ">
    <p class="operate">操作: <a href="#" onclick="checkAll('list-post'); return false;">选择全部</a> , <a href="#" onclick="uncheckAll('list-post'); return false;">全部不选</a>&nbsp;&nbsp;&nbsp;
      选择项: <a href="#" onclick="if(confirm('确定删除?')){postDelete();}return false;">删除</a> </p>
    <table class="list-table" id="list-post">
      <colgroup>
      <col width="25">
       <col width="25">
      <col width="200">
      <col width="100">
      <col width="155">
      <col width="130">
      <col width="150">
      </colgroup>
      <thead>
        <tr>
          <th class="radius-topleft"> </th>
          <th>ID</th>
          <th>标题</th>
          <th>作者</th>
          <th>分类</th>
          <th>评论</th>
          <th class="radius-topright">时间</th>
        </tr>
      </thead>
      <tbody>
      <?php if(is_array($artdata)) foreach($artdata AS $vlaue) { ?> 
        <tr id="post-<?php echo $vlaue["id"];?>">
          <td><input type="checkbox" value="<?php echo $vlaue["id"];?>" name="id[]"></td>
          <td><?php echo $vlaue["id"];?></td>
          <td><a href="#" onclick="ajaxLoad('/admin.php/Admin_Articles/edit/id/<?php echo $vlaue["id"];?>');return false;"><?php echo $vlaue["title"];?></a></td>
          <td><?php echo $vlaue["actor"];?></td>
          <td><?php if($vlaue["categories"] == 0) { ?>顶级分类<?php } ?>
            <?php if(is_array($catall)) foreach($catall AS $v) { ?>
            <?php if($vlaue["categories"]==$v["id"]) { ?><?php echo $v["name"];?><?php } ?>
            <?php } ?>
</td>
          <td><?php echo $vlaue["commentcount"];?> Comment</td>
          <td><?php echo $vlaue["time"];?></td>
        </tr>
        <?php } ?>

      </tbody>
    </table>
    <div class="nav">
<div class="nav-content">
<ul>
<?php if(is_array($page['all_pages'])) foreach($page['all_pages'] AS $vlaue) { ?>
<?php if($page['current_page'] == $vlaue) { ?>
<li class="current">
 <a onclick="ajaxLoad('/admin.php/Admin_Articles/Main/p/<?php echo $vlaue;?>/pages/1');return false;" href="#"><?php echo $vlaue;?></a>
 </li>
<?php } else { ?>
<li>
<a onclick="ajaxLoad('/admin.php/Admin_Articles/Main/p/<?php echo $vlaue;?>/pages/1');return false;" href="#"><?php echo $vlaue;?></a>
</li>
 <?php } ?> 
<?php } ?>


</ul>
</div>
</div>
  </dd>
</dl>
<script>
KindEditor.create('#contentcen', {
minWidth : 800,
minHeight : 400,
allowFileManager : true
});
Tabs(document.getElementById('PostsTabs'), 'select',<?php if($pages == 0) { ?>0<?php } else { ?>1<?php } ?>);

$('#add-post').ajaxForm({
beforeSubmit: function(){	
$("#add-post-submit").attr('disabled',true);
},
success: function(data){

if(data=='ok!') {
showMessage('添加成功！','tips');
$("#add-post-submit").attr('disabled',false);
ajaxLoad('/admin.php/Admin_Articles/Main/pages/2');
} else {
showMessage(data,'error');
}
}});

function postDelete() {
$("#list-post input:checked").each(function(){
$.post(
'/admin.php/Admin_Articles/del',
{'id':$(this).val()},
function(response){
alert(response);
if(response=='ok!'){
showMessage('删除成功','tips');
}
},
"json"
);
});
ajaxLoad('/admin.php/Admin_Articles/Main/pages/2');
}
</script> 